package org.sockettest.server;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class Test {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(11111);
        System.out.println("服务器启动");
        Socket socket = serverSocket.accept();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));

        while (true){
            String str = bufferedReader.readLine();
            if(str.equals("bye")){
                break;
            }
            System.out.println("客户端说: " + str);
        }

        bufferedReader.close();
        socket.close();
        serverSocket.close();
    }
}
